using UnityEngine;
namespace Miya.EmisssionLauncher
{


    public class Emission_Pitch : Emission
    {

        public float Pitch = 0;


        public string PitchArray;


        // Start is called before the first frame update
        public override EmissionData[] GetEmissions(bool _uselooper = true)
        {

            int thiscount = 0;

            if (_uselooper && (_CountLooper != null && _CountLooper.Count > 0))
                thiscount = _CountLooper.Next();
            else
                thiscount = Count;

            thiscount += _CountAddi;

            EmissionData[] _datas = new EmissionData[thiscount];

            if (thiscount <= 0) return _datas;

            int OO = 0;
            if (_uselooper && (_OffsetLooper != null && _OffsetLooper.Count > 0))
                OO = _OffsetLooper.Next();
            else
                OO = Offset;

            float thisoffset = OO;



            float thiswidth = Width + _WidthAddi;

            Vector3 _forward = Quaternion.AngleAxis(Pitch, Vector3.left) * Vector3.forward;
            var steps = SpliteWidth(thiswidth, thiscount);

            for (int i = 0; i < steps.Length; i++)
            {
                _datas[i] = new EmissionData()
                {
                    Owner = transform,
                    Position = Vector3.zero,
                    Direction = Quaternion.AngleAxis(thisoffset + steps[i], Vector3.right) * Vector3.forward,
                    Duration = this.Duration,
                };
            }
            return _datas;

            //var steps = SpliteWidth(Width, thiscount);
            //for (int i = 0; i < count; i++)
            //{
            //    _dirs[i] = new EmissionData()
            //    {
            //        Owner = owner,
            //        Position = Vector3.zero + offset,
            //        Direction = Quaternion.AngleAxis(-1 * _width * 0.5f + i * _step, _axis) * _forward,
            //        Duration = duration,
            //    };
            //}

            //return  Emission._GETDirectOf(transform, op, _forward, Vector3.right, Width, Count,Duration);

        }
    }
}

